<!doctype html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卡莱</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" href="../css/style.css" />
<style>
body{
	background:#f1f1f1;
}

</style>
</head>

<body style="padding:0; ">
	<header>
	 	<a class="returns"></a>
	    <h2>绑定借记卡到微信</h2>
	</header>
	<div class="wrapper">
		<ul class="list m-list" style="margin-top: 10px;">
			<li> 
				<label>卡号</label>
				<input id="cardno"  type="text" value="" class="input" placeholder="请填写结算借记卡卡号">
			</li>
			<li id="name"> 
			 	<label >姓名</label>
			 	<span></span>
			 	</li>
			<li id="certno"> 
			 	<label>身份证</label>
			 	<span></span>
			</li>
	   	 	<li> 
	   	 		<label>选择银行</label>
				<select id="bank">
					<option value ="请选择开卡银行">请选择开卡银行</option>
					<option value ="工商银行">工商银行</option>
					<option value ="招商银行">招商银行</option>
					<option value="中国银行">中国银行</option>
					<option value="建设银行（需开网银）">建设银行（需开网银）</option>
					<option value ="交通银行">交通银行</option>
					<option value ="光大银行">光大银行</option>
					<option value="中信银行（需开网银）">中信银行（需开网银）</option>
					<option value="浦发银行（需开网银）">浦发银行（需开网银）</option>
					<option value ="平安银行">平安银行</option>
					<option value ="广发银行">广发银行</option>
					<option value="兴业银行">兴业银行</option>
					<option value="农业银行">农业银行</option>
					<option value ="邮储银行（需开网银）">邮储银行（需开网银）</option>
					<option value ="民生银行">民生银行</option>
				</select>
		 </li>
	   
	    </ul>
		<a class="btn btn-blue" href="#">确认</a>
</div>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>

<script type="text/javascript">


apiready = function(){

    headerTopCss('1');//头部样式
    var userdata=$api.getStorage('USERDATE');
    $('#name span').text(userdata.name);
    $('#certno span').text(userdata.idber);
    $('.btn-area').on('click',function(){
	    var cardno = $('#cardno').val();
	    if(!cardno){
	    	api.toast({msg: '请输入卡号！',duration: 10000,location: 'middle'});
	    	return;
	    }
	    $api.toast('请稍候!','loading...',30000);
	    var jsons = {
	    	account:userdata.mobile,
	        name:userdata.name,
	        cardno:cardno,
	        certno:userdata.idber,
	        orgno:userdata.orgno
	    };
	    ApiUrl = 'http://121.43.200.118:8080/'
        var desurl = "WechatPay/UpdateBankCard";
        var ObjAjaxValue = new AjaxValueFunasync(desurl,jsons,updateBankCard);
        function updateBankCard(ret){
        	if(ret.RspCd != '000000'){
        		api.hideProgress();
        		api.toast({msg: ret.RspMsg, duration: 1000, location: 'middle'});
        		return;
        	}
        	 
          	$.ajax({
			        url:'http://121.43.200.118:8080/WechatPay/QueryUserInfo',
			        type:'POST',
			        dataType:"json",
			        async:true,
			        cache:false,
			        data:{account:$api.getStorage('usermobile')},//
			        timeout : 30000, //超时时间设置，单位毫秒
			        success: function(ret){
			        	 api.hideProgress();
			             api.openWin({
			                name: 'wchat_pay',
			                url: '../html/wchat_pay.html',
			                reload:true,
			                pageParam:{rate:ret.rate,cardno:ret.cardno},
			                animation:{type:"none"},
			                slidBackEnabled:false
			            });
			            $api.setStorage('WCHATUSER',ret);
			        },
			        error: function(e){
			            errorcallback(e);
			        }
			    });
        }
    	
    })
    
}


</script>
</body>
</html>